home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Shutdown FX 1.3 Source / Shutdown FX ƒ / sfx wipes ƒ / Spiral wipe.c < prev   
Encoding:
C/C++ Source or Header  |  1993-12-14  |  2.8 KB  |  108 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Spiral wipe.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Shutdown FX -=- graphic effects on shutdown
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define BOXSIZE 20
  32. #define CorrectTime 1
  33.  
  34. void SpiralGyra(Pattern *thePattern, int width, int height);
  35.  
  36. /* Start in the topleft corner, facing downwards.  Copy until you hit (a) the
  37.    edge of the screen, or (b) bits you've already copied.  Then turn counter-
  38.    clockwise and do it again.  */
  39.    
  40. void SpiralGyra(Pattern *thePattern, int width, int height)
  41. {
  42.     int            stop,sbottom,sleft,sright,iterrow,itercol,direction;
  43.     Rect        source;
  44.     Boolean        everyOther;
  45.     
  46.     everyOther=FALSE;
  47.     stop=0;
  48.     sbottom=height/BOXSIZE-(height%BOXSIZE ? 0 : 1);
  49.     sleft=0;
  50.     sright=width/BOXSIZE-(width%BOXSIZE ? 0 : 1);
  51.     direction=3;
  52.     iterrow=stop;
  53.     itercol=sleft;
  54.     while ((stop<=sbottom)&&(sleft<=sright))
  55.     {
  56.         StartTiming();
  57.         source.top=iterrow*BOXSIZE;         /* Yes, I know I should recode this */
  58.         source.bottom=source.top+BOXSIZE;   /* to take out multiplication. */
  59.         source.left=itercol*BOXSIZE;        /* If it matters that much to you, */
  60.         source.right=source.left+BOXSIZE;   /* _you_ do it. */
  61.  
  62.         FillRect(&source, *thePattern);
  63.         
  64.         switch (direction)
  65.         {
  66.             case 0:  /* facing right */
  67.                 if (itercol==sright)
  68.                 {
  69.                     sbottom--;
  70.                     direction++;
  71.                     iterrow--;
  72.                 }
  73.                 else itercol++;
  74.                 break;
  75.             case 1:  /* facing up */
  76.                 if (iterrow==stop)   /* that reads "s top," not "stop" */
  77.                 {
  78.                     sright--;
  79.                     direction++;
  80.                     itercol--;
  81.                 }
  82.                 else iterrow--;
  83.                 break;
  84.             case 2:  /* facing left */
  85.                 if (itercol==sleft)
  86.                 {
  87.                     stop++;
  88.                     direction++;
  89.                     iterrow++;
  90.                 }
  91.                 else itercol--;
  92.                 break;
  93.             case 3:  /* facing down */
  94.                 if (iterrow==sbottom)
  95.                 {
  96.                     sleft++;
  97.                     direction=0;
  98.                     itercol++;
  99.                 }
  100.                 else iterrow++;
  101.                 break;
  102.         }
  103.         if (everyOther)
  104.             TimeCorrection(CorrectTime);
  105.         everyOther=!everyOther;
  106.     }
  107. }
  108.